﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using csglxt.model;
using System.Data.SqlClient;

namespace csglxt.DAL
{
   public class AdminService
    {
       public AdminInfo login(string name, string pwd) 
       {
           string Sql = string.Format("select * from useandpwd where AdminName ='{0}' and Adminpass ='{1}'", name, pwd);
           AdminInfo admin = null;
           DBHelper DB = new DBHelper();
           SqlDataReader dr = DB.GetAll(Sql);
           if (dr.Read()) 
           {
               admin = new AdminInfo();
               admin.AdminId = Convert.ToInt32(dr["AdminID"]);
               admin.AdminName = dr["AdminName"].ToString();
               admin.AdminPass = dr["AdminPass"].ToString();
               admin.AdminRole = Convert.ToInt32(dr["AdminRole"]);
               admin.AdminStatus = Convert.ToInt32(dr["AdminStatus"]);          
           }
           dr.Close();
           DB.Close();
           return admin;
       }
        
    }
}
